Skip to content

RUM-3397 (otel-tracer) update otel instrumentation guide for Android#23389

Merged
rtrieu merged 25 commits into
masterfrom
marius/feat/otel-tracer-android
Jun 20, 2024
Merged

RUM-3397 (otel-tracer) update otel instrumentation guide for Android#23389
rtrieu merged 25 commits into
masterfrom
marius/feat/otel-tracer-android

Conversation

@mariusc83

@mariusc83 mariusc83 commented May 28, 2024

Copy link
Copy Markdown
Member

What does this PR do? What is the motivation?

This is part of supporting OTel APIs for dd-sdk-android-trace.

Merge instructions

  • Please merge after reviewing

Additional notes

@github-actions github-actions Bot added the Architecture Everything related to the Doc backend label May 28, 2024
@mariusc83
mariusc83 force-pushed the marius/feat/otel-tracer-android branch 2 times, most recently from 4e76793 to 58234e9 Compare May 28, 2024 13:17

@ganeshnj ganeshnj left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Looks great. Could you add some changes that I did recently in the iOS

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

/informational

We must make sure during the release time, the real version is updated.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

/comment

Let's cleanup the extra spacing like in {{ and ```

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggested change
4. Datadog tracer implements the [Open Telemetry standard][18]. Create the OpenTelemetryTraceProvider and register the OpenTelemetrySdk as GlobalTelemetry instance in your application's `onCreate()` method.
4. Datadog tracer implements the [Open Telemetry standard][18]. Create the `OpenTelemetryTraceProvider` and register the `OpenTelemetrySdk` as GlobalTelemetry instance in your application's `onCreate()` method.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Given the fact, we don't do anything with instrumentationName, let's make it obvious by passing the empty string.

Suggested change
val tracerProvider = GlobalOpenTelemetry.get().getTracer(instrumentationName = "<instrumentation_name>")
val tracerProvider = GlobalOpenTelemetry.get().getTracer(instrumentationName = "")

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

yes but in this case I want to stay consistent with Otel. Maybe later one we will use it for something. Not sure here

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggested change
final TracerProvider tracerProvider = GlobalOpenTelemetry.get().getTracer("<instrumentation_name>");
final TracerProvider tracerProvider = GlobalOpenTelemetry.get().getTracer("");

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggested change
Note: The `setService` method is used to set the service name for the tracer provider. The service name is used to identify the application in the Datadog UI. You can either use the GlobalOpenTelemetry to hold a single instance of the TracerProvider create your own instance of the TracerProvider and use it in your application code as needed.
Note: The `setService` method is used to set the service name for the tracer provider. The service name is used to identify the application in the Datadog UI. You can either use the `GlobalOpenTelemetry` to hold a single instance of the `TracerProvider` create your own instance of the `TracerProvider` and use it in your application code as needed.

Comment thread content/en/tracing/trace_collection/custom_instrumentation/android/otel.md Outdated

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggested change
tracer.spanBuilder("<span_name>").setAttribute("<key_name>", <key_value>).startSpan();
tracer.spanBuilder("<span_name>").setAttribute("<key_name>", "<key_value>").startSpan();

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

nope because if we put it like that will mean that <key_value> should always be a string which is not the case at least in Android API

@mariusc83
mariusc83 force-pushed the marius/feat/otel-tracer-android branch 4 times, most recently from f598d2f to 3f9a200 Compare May 31, 2024 12:42
@mariusc83
mariusc83 marked this pull request as ready for review May 31, 2024 13:27
@mariusc83
mariusc83 requested a review from a team as a code owner May 31, 2024 13:27
@git-thuerk-done

Copy link
Copy Markdown
Contributor

Thanks! I have created a card for our team to review further: https://datadoghq.atlassian.net/browse/DOCS-8112

@git-thuerk-done git-thuerk-done added the editorial review Waiting on a more in-depth review label May 31, 2024
Base automatically changed from ganeshnj/feat/otel-tracer-ios to master June 3, 2024 16:42
@rtrieu
rtrieu requested a review from a team as a code owner June 3, 2024 16:42

@brett0000FF brett0000FF left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for this! I left a few suggestions and comments. Please let me know if you have any questions or need help with anything. 😄 There are some merge conflicts, so I'm waiting to approve.

Comment thread content/en/tracing/trace_collection/custom_instrumentation/android/otel.md Outdated
Comment thread content/en/tracing/trace_collection/automatic_instrumentation/dd_libraries/ios.md Outdated
Comment thread content/en/tracing/trace_collection/custom_instrumentation/android/otel.md Outdated
Comment thread content/en/tracing/trace_collection/custom_instrumentation/android/otel.md Outdated

**Note**: If you decide to set the `GlobalOpenTelemetry.set` API you need to make sure that this is only called one single time in your process otherwise OpenTelemetry will throw an exception. In case you want to avoid that you can just create a `TracerProvider` and use it as a singleton in your project.

**Note**: The `setService` method is used to set the service name for the tracer provider. The service name is used to identify the application in the Datadog UI. You can either use the `GlobalOpenTelemetry` to hold a single instance of the `TracerProvider` create your own instance and use it in your application code as needed.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
**Note**: The `setService` method is used to set the service name for the tracer provider. The service name is used to identify the application in the Datadog UI. You can either use the `GlobalOpenTelemetry` to hold a single instance of the `TracerProvider` create your own instance and use it in your application code as needed.

I think this note is duplicated?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

will double check, tks !!

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I did not find any duplicate, can you please double check it on your end ?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hey, apologies for not being clearer. I was referring to the overlap between the note on line 382 and 384. Perhaps these could be combined?

Ensure the GlobalOpenTelemetry.set API is called only once per process. The setService method is used to set the service name for the tracer provider, which identifies the application in Datadog.

You have two options for managing the TracerProvider instance:

- Use GlobalOpenTelemetry to hold a single instance of the TracerProvider. This ensures that the GlobalOpenTelemetry.set API is called only once per process.
- Create your own instance of the TracerProvider and use it as a singleton in your project. This allows you to manage the instance directly in your application code as needed.

@@ -0,0 +1,327 @@
---
title: iOS and tvOS Custom Instrumentation using OpenTelemetry API

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We recently published a page for this content: https://docs.datadoghq.com/tracing/trace_collection/custom_instrumentation/ios?tab=cocoapods.

I'm not sure which is most relevant, but we should reconcile these.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

yes I need to rebase this ...this is because it was part of @ganeshnj PR that was merged.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

rebase done

@rtrieu rtrieu left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hi @mariusc83, a few minor suggestions from me!

Comment thread content/en/tracing/trace_collection/custom_instrumentation/android/otel.md Outdated
Comment thread content/en/tracing/trace_collection/custom_instrumentation/android/otel.md Outdated
Comment thread content/en/tracing/trace_collection/custom_instrumentation/android/otel.md Outdated
@mariusc83
mariusc83 force-pushed the marius/feat/otel-tracer-android branch from 3f9a200 to 2279085 Compare June 5, 2024 13:59
@mariusc83
mariusc83 force-pushed the marius/feat/otel-tracer-android branch 3 times, most recently from 25c7395 to 282b505 Compare June 7, 2024 09:42
@mariusc83
mariusc83 force-pushed the marius/feat/otel-tracer-android branch from 282b505 to 16b6771 Compare June 11, 2024 12:52

@rtrieu rtrieu left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

A few more things!

Comment thread content/en/tracing/trace_collection/custom_instrumentation/android/otel.md Outdated
Comment thread content/en/tracing/trace_collection/custom_instrumentation/android/otel.md Outdated
Comment thread content/en/tracing/trace_collection/custom_instrumentation/android/otel.md Outdated
Comment thread content/en/tracing/trace_collection/custom_instrumentation/android/otel.md Outdated
Comment thread content/en/tracing/trace_collection/custom_instrumentation/android/otel.md Outdated
Comment thread content/en/tracing/trace_collection/custom_instrumentation/android/otel.md Outdated

@brett0000FF brett0000FF left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks! Just a few minor comments from my end.

Comment thread content/en/tracing/trace_collection/custom_instrumentation/android/otel.md Outdated
Comment thread content/en/tracing/trace_collection/custom_instrumentation/android/otel.md Outdated
@mariusc83
mariusc83 requested a review from rtrieu June 12, 2024 09:30
@mariusc83 mariusc83 self-assigned this Jun 12, 2024

@rtrieu rtrieu left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks great, thanks!

@mariusc83
mariusc83 force-pushed the marius/feat/otel-tracer-android branch from 5f86c32 to 296a786 Compare June 13, 2024 08:12
@MaelNamNam

Copy link
Copy Markdown
Contributor

/merge

@dd-devflow

dd-devflow Bot commented Jun 20, 2024

Copy link
Copy Markdown

🚂 MergeQueue: waiting for PR to be ready

This merge request is not mergeable yet, because of pending checks/missing approvals. It will be added to the queue as soon as checks pass and/or get approvals.
Note: if you pushed new commits since the last approval, you may need additional approval.
You can remove it from the waiting list with /remove command.

Use /merge -c to cancel this operation!

@rtrieu
rtrieu merged commit 603bd34 into master Jun 20, 2024
@rtrieu
rtrieu deleted the marius/feat/otel-tracer-android branch June 20, 2024 13:59
@dd-devflow

dd-devflow Bot commented Jun 20, 2024

Copy link
Copy Markdown

🚂 MergeQueue: This merge request was already merged

This pull request was merged directly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Architecture Everything related to the Doc backend editorial review Waiting on a more in-depth review mergequeue-status: done

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants