Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add OTLP for Activity Exporter #679

Merged

Conversation

pjanotti
Copy link
Contributor

Per our conversation, this is the Activity Exporter for OTLP consuming Activity batches.

I opted at this time to keep ActivityExporter as it is (there was a quick chat on Gitter on perhaps adding the ExportAsync(IEnumerable<Activity>, CancellationToken) but let's have a separate discussion for it).

I will be commenting on some points of the PR to some of the potential issues/follow-ups.

Checklist

  • I ran Unit Tests locally.

// and use Console exporter
OpenTelemetrySdk.EnableOpenTelemetry(
builder => builder
.AddActivitySource("Samples.SampleServer")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cijothomas I'm leaning into listening to all sources by default and filter out un-wanted ones. Depending on how some libraries are instrumented we may need some processors to filter out some activities.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup. Lets address this separately.
Libraries like httpclient, which was instrumented using DiagnosticSource, will have their activities emitted with empty ActivitySource. Listening to them requires AddActivitySource("") now.
Anyway, lets address this after some exporters/adapters are ready with Activity API.

Comment on lines +110 to +122
// TODO: attempt to convert to supported types?
// TODO: enforce no duplicate keys?
// TODO: drop if Value is null?
// TODO: reverse?
var attrib = new OtlpCommon.AttributeKeyValue { Key = kvp.Key, StringValue = kvp.Value };
otlpSpan.Attributes.Add(attrib);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@reyang @cijothomas @noahfalk I think that this is one of the big things to have a wrapper so far: here OTel defines some behaviors that are quite different. In principle, we could have a processor to enforce the OTel spec here but that takes away the control from authors that want to enforce that spec on their code. The OTel related spec: https://github.com/open-telemetry/opentelemetry-specification/blob/bdf39cb935a6f48badc687daeb78a66dc352761f/specification/trace/api.md#set-attributes

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is being addressed in Tarek and Noah. We can live with this now, and hopefully get better solution in next preview of DiagnosticSource.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree this is a valid reason for shim/wrapper to enforce things like no duplicates etc.

private static Dictionary<Resource, Dictionary<ActivitySource, List<OtlpTrace.Span>>> GroupByResourceAndLibrary(
IEnumerable<Activity> activityBatch)
{
// TODO: there is no Resource associated here, other SDKs associate it to the span, that's not an option here.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is already an issue tracking this, see #649.

@@ -79,6 +80,19 @@ public override Task<ExportResult> ExportAsync(IEnumerable<Activity> activityBat
foreach (var activityEvent in activity.Events)
{
System.Console.WriteLine($"Event Name: {activityEvent.Name} TimeStamp: {activityEvent.Timestamp}");
foreach (var attribute in activityEvent.Attributes)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Copy link
Member

@cijothomas cijothomas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. left a comment about DisplayName.

@pjanotti pjanotti force-pushed the add-activity-support-to-otlp branch from f1343c3 to 9b5f3d6 Compare May 18, 2020 23:57
@cijothomas cijothomas mentioned this pull request May 19, 2020
32 tasks
@MikeGoldsmith MikeGoldsmith merged commit 0c01cc7 into open-telemetry:master May 19, 2020
SergeyKanzhelev pushed a commit that referenced this pull request May 20, 2020
* add Paulo as the approver

* update CODEOWNERS

* fix nit

* Add OTLP for Activity Exporter  (#679)

* Add OTLP Exporter for Activity

* Initial PR feedback

* Check ID format and use DisplayName

* Skip the activity instances that could not be translated

Co-authored-by: Cijo Thomas <[email protected]>

* Rename Adapter to Instrumentation per latest spec (#681)

Co-authored-by: Mike Goldsmith <[email protected]>

Co-authored-by: Paulo Janotti <[email protected]>
Co-authored-by: Cijo Thomas <[email protected]>
Co-authored-by: Mike Goldsmith <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants