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 extension functions and example for OpenTelemetry #187

Merged
merged 6 commits into from
Feb 20, 2024
Merged

Conversation

marychatte
Copy link
Member

@marychatte marychatte self-assigned this Feb 6, 2024
Copy link

@github-advanced-security github-advanced-security bot left a comment

Choose a reason for hiding this comment

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

detekt found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.

@marychatte marychatte requested a review from e5l February 6, 2024 11:35
@e5l e5l requested a review from garthgilmourni February 6, 2024 11:58
@e5l
Copy link
Member

e5l commented Feb 6, 2024

@garthgilmourni, please also take a look

Copy link
Member

@e5l e5l left a comment

Choose a reason for hiding this comment

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

Hey @marychatte, good job on this!

LGTM in general, please address some small comments before merging

opentelemetry/build.gradle.kts Show resolved Hide resolved
opentelemetry/client/build.gradle.kts Outdated Show resolved Hide resolved
fun Application.configureRouting() {
install(WebSockets)

val openTelemetry = installOpenTelemetryOnServer()
Copy link
Member

Choose a reason for hiding this comment

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

Can it be an extension on application (stored in the attributes)?

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for the review! I'm not sure about an extension on the application, because users should provide an instance of OpenTelemetry by themselves (in our example we do it in fun getOpenTelemetry(...) from utils.kt). But please correct me if I misunderstood you

@marychatte marychatte requested a review from e5l February 19, 2024 14:44
@e5l
Copy link
Member

e5l commented Feb 20, 2024

@vnikolova, could you please check readme files?

@e5l e5l requested a review from vnikolova February 20, 2024 08:58
Copy link
Contributor

@vnikolova vnikolova left a comment

Choose a reason for hiding this comment

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

That's a pretty cool example! Regarding the README, I think it makes sense to do the following reordering of the sections:

  1. This paragraph goes in first: "OpenTelemetry provides support for Ktor with the KtorClientTracing and KtorServerTracing plugins for the Ktor client and server respectively. For the source code, see the repository on GitHub. "

  2. then goes the content from the "Motivation" section, without the title.

  3. "Running"

  4. the content from "Examples", without the title.

Please see my comments for a few more small edits to improve readability :)


**Note:** You need to have [Docker](https://www.docker.com/) installed and running to run the sample.

To run a sample, first, execute the following command in an `opentelemetry` directory:
Copy link
Contributor

Choose a reason for hiding this comment

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

Edit: "To run this sample, execute the following command from the opentelemetry directory:"

./gradlew :client:run
```

[OpenTelemetry](https://opentelemetry.io/) has support for `Ktor`, you can find source
Copy link
Contributor

Choose a reason for hiding this comment

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

This feels like an introduction. Can we move it to the top of the document?

## Motivation

This project contains extension functions for plugins that allow you to write code in the Ktor DSL style. \
For example, you can rewrite the next code:
Copy link
Contributor

Choose a reason for hiding this comment

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

Edit: "Take the following code as an example:"

}
```

To a more readable for `Ktor` style:
Copy link
Contributor

Choose a reason for hiding this comment

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

Edit: "Rewritten in Ktor DSL style, it looks like the following:"


Let's see what we will see in the `Jaeger UI` after running the server (with Docker) and client:

1. We can see two services that send opentelemetry data: `opentelemetry-ktor-sample-server`
Copy link
Contributor

Choose a reason for hiding this comment

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

I also see a third service jaeger-all-in-one (looking at http://localhost:16686/search)

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we also need one sep prior to clarify the URL the user should navigate to.

1. We can see two services that send opentelemetry data: `opentelemetry-ktor-sample-server`
and `opentelemetry-ktor-sample-client`:
![img.png](images/1.png)
2. If we choose `opentelemetry-ktor-sample-server` service, we will see the next traces:
Copy link
Contributor

Choose a reason for hiding this comment

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

Edit: "If you select opentelemetry-ktor-sample-server service and click on Find traces, you will see a list of traces:"

![img.png](images/1.png)
2. If we choose `opentelemetry-ktor-sample-server` service, we will see the next traces:
![img.png](images/2.png)
3. And if we choose one of the traces:
Copy link
Contributor

Choose a reason for hiding this comment

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

Edit: "If you click on one of those traces, you will be navigated to a screen providing detailed information about the selected trace."

@marychatte marychatte requested a review from vnikolova February 20, 2024 15:32
@marychatte marychatte merged commit 4ffe6b8 into main Feb 20, 2024
2 checks passed
@marychatte marychatte deleted the opentelemetry branch February 20, 2024 19:48
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.

4 participants