Skip to content

Commit

Permalink
resolving merge conflicts with master
Browse files Browse the repository at this point in the history
  • Loading branch information
nprajilesh committed Oct 8, 2020
2 parents 16ac274 + affe911 commit b0de4f8
Show file tree
Hide file tree
Showing 94 changed files with 1,190 additions and 607 deletions.
3 changes: 2 additions & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,8 @@ exclude-protected=_asdict,
_fields,
_replace,
_source,
_make
_make,
_Span

# List of valid names for the first argument in a class method.
valid-classmethod-first-arg=cls
Expand Down
4 changes: 2 additions & 2 deletions docs/getting_started/prometheus_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
# Start Prometheus client
start_http_server(port=8000, addr="localhost")

batcher_mode = "stateful"
processor_mode = "stateful"
metrics.set_meter_provider(MeterProvider())
meter = metrics.get_meter(__name__, batcher_mode == "stateful")
meter = metrics.get_meter(__name__, processor_mode == "stateful")
exporter = PrometheusMetricsExporter("MyAppPrefix")
controller = PushController(meter, exporter, 5)

Expand Down
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ In addition, there are several extension packages which can be installed separat
pip install opentelemetry-instrumentation-{instrumentation}

These are for exporter and instrumentation packages respectively.
The packages can be found in :scm_web:`instrumentation/ directory of the repository <ext/>`.
The packages can be found in :scm_web:`instrumentation/ directory of the repository <exporter/>`.

Extensions
----------
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
opentelemetry.sdk.metrics.export.batcher
opentelemetry.sdk.metrics.export.processor
==========================================

.. toctree::

metrics.export

.. automodule:: opentelemetry.sdk.metrics.export.batcher
.. automodule:: opentelemetry.sdk.metrics.export.processor
:members:
:undoc-members:
:show-inheritance:
2 changes: 1 addition & 1 deletion docs/sdk/metrics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Submodules
.. toctree::

metrics.export.aggregate
metrics.export.batcher
metrics.export.processor
util.instrumentation

.. automodule:: opentelemetry.sdk.metrics
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,12 +189,12 @@ def _translate_to_datadog(self, spans):

def _get_trace_ids(span):
"""Extract tracer ids from span"""
ctx = span.get_context()
ctx = span.get_span_context()
trace_id = ctx.trace_id
span_id = ctx.span_id

if isinstance(span.parent, trace_api.Span):
parent_id = span.parent.get_context().span_id
parent_id = span.parent.get_span_context().span_id
elif isinstance(span.parent, trace_api.SpanContext):
parent_id = span.parent.span_id
else:
Expand Down Expand Up @@ -255,13 +255,13 @@ def _get_exc_info(span):


def _get_origin(span):
ctx = span.get_context()
ctx = span.get_span_context()
origin = ctx.trace_state.get(DD_ORIGIN)
return origin


def _get_sampling_rate(span):
ctx = span.get_context()
ctx = span.get_span_context()
return (
span.sampler.rate
if ctx.trace_flags.sampled
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def inject(
context: typing.Optional[Context] = None,
) -> None:
span = get_current_span(context)
span_context = span.get_context()
span_context = span.get_span_context()
if span_context == trace.INVALID_SPAN_CONTEXT:
return
sampled = (trace.TraceFlags.SAMPLED & span.context.trace_flags) != 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def __init__(
self.worker_thread.start()

def on_start(self, span: Span) -> None:
ctx = span.get_context()
ctx = span.get_span_context()
trace_id = ctx.trace_id

with self.traces_lock:
Expand All @@ -102,7 +102,7 @@ def on_end(self, span: Span) -> None:
logger.warning("Already shutdown, dropping span.")
return

ctx = span.get_context()
ctx = span.get_span_context()
trace_id = ctx.trace_id

with self.traces_lock:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ def test_translate_to_datadog(self):
span_context = trace_api.SpanContext(
trace_id, span_id, is_remote=False
)
parent_context = trace_api.SpanContext(
parent_span_context = trace_api.SpanContext(
trace_id, parent_id, is_remote=False
)
other_context = trace_api.SpanContext(
Expand All @@ -188,22 +188,22 @@ def test_translate_to_datadog(self):
instrumentation_info = InstrumentationInfo(__name__, "0")

otel_spans = [
trace.Span(
trace._Span(
name=span_names[0],
context=span_context,
parent=parent_context,
parent=parent_span_context,
kind=trace_api.SpanKind.CLIENT,
instrumentation_info=instrumentation_info,
resource=Resource({}),
),
trace.Span(
trace._Span(
name=span_names[1],
context=parent_context,
context=parent_span_context,
parent=None,
instrumentation_info=instrumentation_info,
resource=resource_without_service,
),
trace.Span(
trace._Span(
name=span_names[2],
context=other_context,
parent=None,
Expand Down Expand Up @@ -289,7 +289,7 @@ def test_export(self):
is_remote=False,
)

test_span = trace.Span("test_span", context=context)
test_span = trace._Span("test_span", context=context)
test_span.start()
test_span.end()

Expand Down Expand Up @@ -492,8 +492,8 @@ def test_origin(self):
),
)

root_span = trace.Span(name="root", context=context, parent=None)
child_span = trace.Span(
root_span = trace._Span(name="root", context=context, parent=None)
child_span = trace._Span(
name="child", context=context, parent=root_span
)
root_span.start()
Expand Down Expand Up @@ -528,7 +528,7 @@ def test_sampling_rate(self):
)
sampler = sampling.TraceIdRatioBased(0.5)

span = trace.Span(
span = trace._Span(
name="sampled", context=context, parent=None, sampler=sampler
)
span.start()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def test_malformed_headers(self):
malformed_parent_id_key: self.serialized_parent_id,
},
)
).get_context()
).get_span_context()

self.assertNotEqual(context.trace_id, int(self.serialized_trace_id))
self.assertNotEqual(context.span_id, int(self.serialized_parent_id))
Expand All @@ -62,7 +62,7 @@ def test_missing_trace_id(self):
}

ctx = FORMAT.extract(getter, carrier)
span_context = get_current_span(ctx).get_context()
span_context = get_current_span(ctx).get_span_context()
self.assertEqual(span_context.trace_id, trace_api.INVALID_TRACE_ID)

def test_missing_parent_id(self):
Expand All @@ -72,12 +72,12 @@ def test_missing_parent_id(self):
}

ctx = FORMAT.extract(getter, carrier)
span_context = get_current_span(ctx).get_context()
span_context = get_current_span(ctx).get_span_context()
self.assertEqual(span_context.span_id, trace_api.INVALID_SPAN_ID)

def test_context_propagation(self):
"""Test the propagation of Datadog headers."""
parent_context = get_current_span(
parent_span_context = get_current_span(
FORMAT.extract(
getter,
{
Expand All @@ -87,31 +87,31 @@ def test_context_propagation(self):
FORMAT.ORIGIN_KEY: self.serialized_origin,
},
)
).get_context()
).get_span_context()

self.assertEqual(
parent_context.trace_id, int(self.serialized_trace_id)
parent_span_context.trace_id, int(self.serialized_trace_id)
)
self.assertEqual(
parent_context.span_id, int(self.serialized_parent_id)
parent_span_context.span_id, int(self.serialized_parent_id)
)
self.assertEqual(parent_context.trace_flags, constants.AUTO_KEEP)
self.assertEqual(parent_span_context.trace_flags, constants.AUTO_KEEP)
self.assertEqual(
parent_context.trace_state.get(constants.DD_ORIGIN),
parent_span_context.trace_state.get(constants.DD_ORIGIN),
self.serialized_origin,
)
self.assertTrue(parent_context.is_remote)
self.assertTrue(parent_span_context.is_remote)

child = trace.Span(
child = trace._Span(
"child",
trace_api.SpanContext(
parent_context.trace_id,
parent_span_context.trace_id,
trace_api.RandomIdsGenerator().generate_span_id(),
is_remote=False,
trace_flags=parent_context.trace_flags,
trace_state=parent_context.trace_state,
trace_flags=parent_span_context.trace_flags,
trace_state=parent_span_context.trace_state,
),
parent=parent_context,
parent=parent_span_context,
)

child_carrier = {}
Expand All @@ -134,7 +134,7 @@ def test_context_propagation(self):

def test_sampling_priority_auto_reject(self):
"""Test sampling priority rejected."""
parent_context = get_current_span(
parent_span_context = get_current_span(
FORMAT.extract(
getter,
{
Expand All @@ -143,20 +143,22 @@ def test_sampling_priority_auto_reject(self):
FORMAT.SAMPLING_PRIORITY_KEY: str(constants.AUTO_REJECT),
},
)
).get_context()
).get_span_context()

self.assertEqual(parent_context.trace_flags, constants.AUTO_REJECT)
self.assertEqual(
parent_span_context.trace_flags, constants.AUTO_REJECT
)

child = trace.Span(
child = trace._Span(
"child",
trace_api.SpanContext(
parent_context.trace_id,
parent_span_context.trace_id,
trace_api.RandomIdsGenerator().generate_span_id(),
is_remote=False,
trace_flags=parent_context.trace_flags,
trace_state=parent_context.trace_state,
trace_flags=parent_span_context.trace_flags,
trace_state=parent_span_context.trace_state,
),
parent=parent_context,
parent=parent_span_context,
)

child_carrier = {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
foo.set_attribute("my_atribbute", True)
foo.add_event("event in foo", {"name": "foo1"})
with tracer.start_as_current_span(
"bar", links=[trace.Link(foo.get_context())]
"bar", links=[trace.Link(foo.get_span_context())]
) as bar:
time.sleep(0.2)
bar.set_attribute("speed", 100.0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ def _translate_to_jaeger(spans: Span):
jaeger_spans = []

for span in spans:
ctx = span.get_context()
ctx = span.get_span_context()
trace_id = ctx.trace_id
span_id = ctx.span_id

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def setUp(self):
is_remote=False,
)

self._test_span = trace.Span("test_span", context=context)
self._test_span = trace._Span("test_span", context=context)
self._test_span.start()
self._test_span.end()

Expand Down Expand Up @@ -144,7 +144,7 @@ def test_translate_to_jaeger(self):
span_context = trace_api.SpanContext(
trace_id, span_id, is_remote=False
)
parent_context = trace_api.SpanContext(
parent_span_context = trace_api.SpanContext(
trace_id, parent_id, is_remote=False
)
other_context = trace_api.SpanContext(
Expand Down Expand Up @@ -187,18 +187,20 @@ def test_translate_to_jaeger(self):
]

otel_spans = [
trace.Span(
trace._Span(
name=span_names[0],
context=span_context,
parent=parent_context,
parent=parent_span_context,
events=(event,),
links=(link,),
kind=trace_api.SpanKind.CLIENT,
),
trace.Span(
name=span_names[1], context=parent_context, parent=None
trace._Span(
name=span_names[1], context=parent_span_context, parent=None
),
trace._Span(
name=span_names[2], context=other_context, parent=None
),
trace.Span(name=span_names[2], context=other_context, parent=None),
]

otel_spans[0].start(start_time=start_times[0])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def translate_to_collector(

# If cumulative and stateful, explicitly set the start_timestamp to
# exporter start time.
if metric_record.instrument.meter.batcher.stateful:
if metric_record.instrument.meter.processor.stateful:
start_timestamp = exporter_start_timestamp
else:
start_timestamp = None
Expand Down Expand Up @@ -191,7 +191,7 @@ def get_collector_point(metric_record: MetricRecord) -> metrics_pb2.Point:


def get_resource(metric_record: MetricRecord) -> resource_pb2.Resource:
resource_attributes = metric_record.instrument.meter.resource.attributes
resource_attributes = metric_record.resource.attributes
return resource_pb2.Resource(
type=infer_oc_resource_type(resource_attributes),
labels={k: str(v) for k, v in resource_attributes.items()},
Expand Down
Loading

0 comments on commit b0de4f8

Please sign in to comment.