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 tracing #8

Merged
merged 18 commits into from
Jun 2, 2022
Merged

Add tracing #8

merged 18 commits into from
Jun 2, 2022

Conversation

bfmatei
Copy link
Collaborator

@bfmatei bfmatei commented Mar 7, 2022

fixes #10

@bfmatei bfmatei requested review from domasx2 and kpelelis March 7, 2022 12:17
Copy link
Collaborator

@domasx2 domasx2 left a comment

Choose a reason for hiding this comment

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

some random comments.
But overall I feel we should use @opentelemetry/sdk-trace-web for this 🤔
dev resources are most precious for us, I feel like any negatives are outweighed by burden of maintaining an alternative impl

packages/core/src/api/measurements/types.ts Outdated Show resolved Hide resolved
packages/core/src/api/traces/types.ts Outdated Show resolved Hide resolved
packages/core/src/api/traces/types.ts Outdated Show resolved Hide resolved
packages/core/src/api/traces/initialize.ts Outdated Show resolved Hide resolved
packages/core/src/api/exceptions/initialize.ts Outdated Show resolved Hide resolved
packages/core/src/api/traces/initialize.ts Outdated Show resolved Hide resolved
packages/instrumentation-tracing-web/src/index.ts Outdated Show resolved Hide resolved
@domasx2 domasx2 marked this pull request as ready for review May 26, 2022 09:28
@domasx2 domasx2 self-requested a review May 26, 2022 09:28
domasx2
domasx2 previously approved these changes May 26, 2022
Copy link
Collaborator Author

@bfmatei bfmatei left a comment

Choose a reason for hiding this comment

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

A couple of comments

package.json Outdated
@@ -35,31 +35,33 @@
"git-hooks:pre-commit": "lint-staged",
"drone": "run-s drone:lint drone:sign",
"drone:lint": "drone lint .drone/drone.yml --trusted",
"drone:sign": "drone --server https://drone.grafana.net sign --save grafana/grafana-javascript-agent .drone/drone.yml"
"drone:sign": "drone --server https://drone.grafana.net sign --save grafana/grafana-javascript-agent .drone/drone.yml",
"postinstall": "npm explore @opentelemetry/otlp-exporter-base -- cp -r build/src build/esm"
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Let's use cpy instead of cp as people may have issues on Windows machines.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Copy link
Collaborator

@domasx2 domasx2 May 31, 2022

Choose a reason for hiding this comment

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

It seems a new version was released that fixes the problem being sovled here hopefully, maybe we can get rid of this hook!

Copy link
Collaborator

Choose a reason for hiding this comment

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

New version breaks payload compat with version of otel collector used by grafana agent, and still has a build issue: open-telemetry/opentelemetry-js#2998

Copy link
Collaborator

Choose a reason for hiding this comment

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

cpy-cli does not work like cp, ends up with an odd dir hierarchy. Ended up using shx: https://www.npmjs.com/package/shx

@@ -15,7 +15,7 @@
"scripts": {
"start": "parcel serve",
"build": "parcel build",
"clean": "rimraf dist/",
"clean": "rimraf dist/ yarn-error.log",
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Is yarn-error.log something that has to be removed? Originally clean was responsible with cleaning the build caches rather than logs.

Copy link
Collaborator

Choose a reason for hiding this comment

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

This change was made by you :) Shall I remove it?

@@ -1,42 +1,59 @@
function throwError() {
import '@grafana/agent-web/dist/globals';
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Should we export this through a barrel rather than importing it like this?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I wanted extending a global type to be explicit choice rather than happening automatically by importing from a barrel.
Two reasons:

  • It might be wrong if you renamed the global from "grafanaAgent" via config
  • Extending global types can be contraversial

packages/tracing-web/src/otel/agent-exporter.ts Outdated Show resolved Hide resolved
packages/tracing-web/src/instrumentation.ts Outdated Show resolved Hide resolved
packages/tracing-web/src/instrumentation.ts Outdated Show resolved Hide resolved

// trace context for logs, exceptions, measurements
export interface TraceContext {
trace_id: string;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Should we move to camelcase instead of snakecase?

Copy link
Collaborator

Choose a reason for hiding this comment

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

no, this goes straight to json where it should be sanke cased. Unless we want to rewrite it later?

Copy link
Collaborator

Choose a reason for hiding this comment

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

actually I'm not sure that go unmarshaller won't auto convert 🤔 will test later


const getTraceContext = (): TraceContext | undefined => {
if (otel) {
const ctx = otel.trace.getSpanContext(otel.context.active());
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Should we create some helpers for OTel packages? I see a need for getCurrentContext and getCurrentSpan

Copy link
Collaborator

Choose a reason for hiding this comment

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

I feel we should just use otel api and avoid adding any layers on top of it. This is less confusing (one way to do things), and I think we don't really have enough experience to be opinionated about it

packages/core/src/api/measurements/types.ts Outdated Show resolved Hide resolved
domasx2
domasx2 previously approved these changes Jun 2, 2022
domasx2 and others added 2 commits June 2, 2022 16:35
* add simplified web initializer

* re-disable LogLevel.LOG for console instrumentation

* getDefaultInstrumentations -> getWebInstrumentations
@domasx2 domasx2 merged commit b5bc7c4 into main Jun 2, 2022
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.

Add tracing support
2 participants