Skip to content

Commit

Permalink
Add Infinite Tracing Protobuf v5 Files (#1241)
Browse files Browse the repository at this point in the history
* Add infinite tracing protobuf v5 files

* Attempt to load protobuf files without version checks

* Revert to using protobuf version for imports

---------

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
  • Loading branch information
TimPansino and mergify[bot] authored Nov 6, 2024
1 parent eadaff6 commit 791c0a7
Show file tree
Hide file tree
Showing 6 changed files with 124 additions and 5 deletions.
41 changes: 41 additions & 0 deletions newrelic/core/infinite_tracing.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Generate pb2 files using the following command:
// python -m grpc_tools.protoc --proto_path=newrelic/core --python_out=newrelic/core newrelic/core/infinite_tracing.proto

syntax = "proto3";

package com.newrelic.trace.v1;

service IngestService {
// Accepts a stream of Span messages, and returns an irregular stream of
// RecordStatus messages.
rpc RecordSpan(stream Span) returns (stream RecordStatus) {}

// Accepts a stream of SpanBatch messages, and returns an irregular
// stream of RecordStatus messages. This endpoint can be used to improve
// throughput when Span messages are small
rpc RecordSpanBatch(stream SpanBatch) returns (stream RecordStatus) {}
}

message SpanBatch {
repeated Span spans = 1;
}

message Span {
string trace_id = 1;
map<string, AttributeValue> intrinsics = 2;
map<string, AttributeValue> user_attributes = 3;
map<string, AttributeValue> agent_attributes = 4;
}

message AttributeValue {
oneof value {
string string_value = 1;
bool bool_value = 2;
int64 int_value = 3;
double double_value = 4;
}
}

message RecordStatus {
uint64 messages_seen = 1;
}
9 changes: 8 additions & 1 deletion newrelic/core/infinite_tracing_pb2.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,14 @@
PROTOBUF_VERSION = (0, 0, 0)

# Import appropriate generated pb2 file for protobuf version
if PROTOBUF_VERSION >= (4,):
if PROTOBUF_VERSION >= (5,):
from newrelic.core.infinite_tracing_v5_pb2 import ( # noqa: F401; pylint: disable=W0611
AttributeValue,
RecordStatus,
Span,
SpanBatch,
)
elif PROTOBUF_VERSION >= (4,):
from newrelic.core.infinite_tracing_v4_pb2 import ( # noqa: F401; pylint: disable=W0611
AttributeValue,
RecordStatus,
Expand Down
2 changes: 1 addition & 1 deletion newrelic/core/infinite_tracing_v3_pb2.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.

# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: v1.proto
# source: infinite_tracing.proto
"""Generated protocol buffer code."""
from google.protobuf import descriptor as _descriptor
from google.protobuf import descriptor_pool as _descriptor_pool
Expand Down
2 changes: 1 addition & 1 deletion newrelic/core/infinite_tracing_v4_pb2.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.

# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: v1.proto
# source: infinite_tracing.proto
"""Generated protocol buffer code."""
from google.protobuf import descriptor as _descriptor
from google.protobuf import descriptor_pool as _descriptor_pool
Expand Down
70 changes: 70 additions & 0 deletions newrelic/core/infinite_tracing_v5_pb2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# -*- coding: utf-8 -*-
# # Copyright 2010 New Relic, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Generated by the protocol buffer compiler. DO NOT EDIT!
# NO CHECKED-IN PROTOBUF GENCODE
# source: infinite_tracing.proto
# Protobuf Python Version: 5.27.2
"""Generated protocol buffer code."""
from google.protobuf import descriptor as _descriptor
from google.protobuf import descriptor_pool as _descriptor_pool
from google.protobuf import runtime_version as _runtime_version
from google.protobuf import symbol_database as _symbol_database
from google.protobuf.internal import builder as _builder
_runtime_version.ValidateProtobufRuntimeVersion(
_runtime_version.Domain.PUBLIC,
5,
27,
2,
'',
'infinite_tracing.proto'
)
# @@protoc_insertion_point(imports)

_sym_db = _symbol_database.Default()




DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x16infinite_tracing.proto\x12\x15\x63om.newrelic.trace.v1\"7\n\tSpanBatch\x12*\n\x05spans\x18\x01 \x03(\x0b\x32\x1b.com.newrelic.trace.v1.Span\"\x86\x04\n\x04Span\x12\x10\n\x08trace_id\x18\x01 \x01(\t\x12?\n\nintrinsics\x18\x02 \x03(\x0b\x32+.com.newrelic.trace.v1.Span.IntrinsicsEntry\x12H\n\x0fuser_attributes\x18\x03 \x03(\x0b\x32/.com.newrelic.trace.v1.Span.UserAttributesEntry\x12J\n\x10\x61gent_attributes\x18\x04 \x03(\x0b\x32\x30.com.newrelic.trace.v1.Span.AgentAttributesEntry\x1aX\n\x0fIntrinsicsEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\x34\n\x05value\x18\x02 \x01(\x0b\x32%.com.newrelic.trace.v1.AttributeValue:\x02\x38\x01\x1a\\\n\x13UserAttributesEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\x34\n\x05value\x18\x02 \x01(\x0b\x32%.com.newrelic.trace.v1.AttributeValue:\x02\x38\x01\x1a]\n\x14\x41gentAttributesEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\x34\n\x05value\x18\x02 \x01(\x0b\x32%.com.newrelic.trace.v1.AttributeValue:\x02\x38\x01\"t\n\x0e\x41ttributeValue\x12\x16\n\x0cstring_value\x18\x01 \x01(\tH\x00\x12\x14\n\nbool_value\x18\x02 \x01(\x08H\x00\x12\x13\n\tint_value\x18\x03 \x01(\x03H\x00\x12\x16\n\x0c\x64ouble_value\x18\x04 \x01(\x01H\x00\x42\x07\n\x05value\"%\n\x0cRecordStatus\x12\x15\n\rmessages_seen\x18\x01 \x01(\x04\x32\xc5\x01\n\rIngestService\x12T\n\nRecordSpan\x12\x1b.com.newrelic.trace.v1.Span\x1a#.com.newrelic.trace.v1.RecordStatus\"\x00(\x01\x30\x01\x12^\n\x0fRecordSpanBatch\x12 .com.newrelic.trace.v1.SpanBatch\x1a#.com.newrelic.trace.v1.RecordStatus\"\x00(\x01\x30\x01\x62\x06proto3')

_globals = globals()
_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals)
_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'infinite_tracing_pb2', _globals)
if not _descriptor._USE_C_DESCRIPTORS:
DESCRIPTOR._loaded_options = None
_globals['_SPAN_INTRINSICSENTRY']._loaded_options = None
_globals['_SPAN_INTRINSICSENTRY']._serialized_options = b'8\001'
_globals['_SPAN_USERATTRIBUTESENTRY']._loaded_options = None
_globals['_SPAN_USERATTRIBUTESENTRY']._serialized_options = b'8\001'
_globals['_SPAN_AGENTATTRIBUTESENTRY']._loaded_options = None
_globals['_SPAN_AGENTATTRIBUTESENTRY']._serialized_options = b'8\001'
_globals['_SPANBATCH']._serialized_start=49
_globals['_SPANBATCH']._serialized_end=104
_globals['_SPAN']._serialized_start=107
_globals['_SPAN']._serialized_end=625
_globals['_SPAN_INTRINSICSENTRY']._serialized_start=348
_globals['_SPAN_INTRINSICSENTRY']._serialized_end=436
_globals['_SPAN_USERATTRIBUTESENTRY']._serialized_start=438
_globals['_SPAN_USERATTRIBUTESENTRY']._serialized_end=530
_globals['_SPAN_AGENTATTRIBUTESENTRY']._serialized_start=532
_globals['_SPAN_AGENTATTRIBUTESENTRY']._serialized_end=625
_globals['_ATTRIBUTEVALUE']._serialized_start=627
_globals['_ATTRIBUTEVALUE']._serialized_end=743
_globals['_RECORDSTATUS']._serialized_start=745
_globals['_RECORDSTATUS']._serialized_end=782
_globals['_INGESTSERVICE']._serialized_start=785
_globals['_INGESTSERVICE']._serialized_end=982
# @@protoc_insertion_point(module_scope)
5 changes: 3 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ envlist =
python-adapter_waitress-{py37,py38,py39}-waitress010404,
python-agent_features-{py37,py38,py39,py310,py311,py312,py313}-{with,without}_extensions,
python-agent_features-pypy310-without_extensions,
python-agent_streaming-{py37,py38,py39,py310,py311,py312,py313}-protobuf04-{with,without}_extensions,
python-agent_streaming-py39-protobuf{03,0319}-{with,without}_extensions,
python-agent_streaming-{py37,py38,py39,py310,py311,py312,py313}-protobuf05-{with,without}_extensions,
python-agent_streaming-py39-protobuf{03,0319,04}-{with,without}_extensions,
python-agent_unittests-{py37,py38,py39,py310,py311,py312,py313}-{with,without}_extensions,
python-agent_unittests-pypy310-without_extensions,
python-application_celery-{py37,py38,py39,py310,py311,py312,py313,pypy310}-celerylatest,
Expand Down Expand Up @@ -219,6 +219,7 @@ deps =
adapter_waitress-waitresslatest: waitress
agent_features: beautifulsoup4
agent_features: protobuf
agent_streaming-protobuf05: protobuf<6
agent_streaming-protobuf04: protobuf<5
agent_streaming-protobuf03: protobuf<4
agent_streaming-protobuf0319: protobuf<3.20
Expand Down

0 comments on commit 791c0a7

Please sign in to comment.