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

Api separation #727

Merged
Merged

Conversation

dyladan
Copy link
Member

@dyladan dyladan commented Jan 22, 2020

Which problem is this PR solving?

Short description of the changes

  • Rename @opentelemetry/types to @opentelemetry/api
  • Move API related concerns such as get/set tracer/meter registries to @opentelemetry/api
  • Move all noop implementations to @opentelemetry/api

TODO:

  • update all README files
  • update examples
  • update getting started
  • update benchmarks
  • browser tests for API

@codecov-io
Copy link

codecov-io commented Jan 23, 2020

Codecov Report

Merging #727 into master will decrease coverage by 1.45%.
The diff coverage is 100%.

@@            Coverage Diff             @@
##           master     #727      +/-   ##
==========================================
- Coverage   92.47%   91.01%   -1.46%     
==========================================
  Files         234      234              
  Lines       10475    10599     +124     
  Branches      944      959      +15     
==========================================
- Hits         9687     9647      -40     
- Misses        788      952     +164
Impacted Files Coverage Δ
...ckages/opentelemetry-plugin-ioredis/src/ioredis.ts 100% <100%> (ø) ⬆️
...lemetry-plugin-http/test/functionals/utils.test.ts 99.37% <100%> (+0.02%) ⬆️
...try-propagator-jaeger/src/JaegerHttpTraceFormat.ts 95.65% <100%> (ø) ⬆️
packages/opentelemetry-plugin-http/src/utils.ts 97.26% <100%> (-0.66%) ⬇️
...opagator-jaeger/test/JaegerHttpTraceFormat.test.ts 100% <100%> (ø) ⬆️
...y-plugin-http/test/functionals/http-enable.test.ts 96.21% <100%> (ø) ⬆️
packages/opentelemetry-core/test/utils/url.test.ts 50% <0%> (-50%) ⬇️
...pentelemetry-core/test/internal/validators.test.ts 50% <0%> (-50%) ⬇️
...elemetry-core/test/trace/spancontext-utils.test.ts 55.55% <0%> (-44.45%) ⬇️
...lemetry-core/test/trace/ProbabilitySampler.test.ts 56.52% <0%> (-43.48%) ⬇️
... and 33 more

Copy link
Member

@mayurkale22 mayurkale22 left a comment

Choose a reason for hiding this comment

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

Overall I like the idea, added a few comments in the first phase.

packages/opentelemetry-api/package.json Outdated Show resolved Hide resolved
packages/opentelemetry-api/package.json Outdated Show resolved Hide resolved
packages/opentelemetry-api/src/api/tracing.ts Outdated Show resolved Hide resolved
packages/opentelemetry-api/src/api/tracing.ts Outdated Show resolved Hide resolved
packages/opentelemetry-api/src/index.ts Outdated Show resolved Hide resolved
packages/opentelemetry-api/test/noop-meter.test.ts Outdated Show resolved Hide resolved
packages/opentelemetry-api/package.json Show resolved Hide resolved
Copy link
Member

@vmarchaud vmarchaud left a comment

Choose a reason for hiding this comment

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

i didn't reviewed every files but it seems good, i mostly want to say that i agree with that changes.

Copy link
Member

@obecny obecny left a comment

Choose a reason for hiding this comment

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

left few comments, lgtm, although not sure if we should change it this now or later for safety and also this change should be released with major version, not patch

packages/opentelemetry-api/src/api/trace.ts Show resolved Hide resolved
packages/opentelemetry-api/src/api/trace.ts Show resolved Hide resolved
packages/opentelemetry-api/src/api/trace.ts Show resolved Hide resolved
}

/**
* Set the current global tracer. Returns the initialized global tracer registry
Copy link
Member

Choose a reason for hiding this comment

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

if this function only sets registry, it should have different name then init
Maybe add or set because it doesn't init anything

Copy link
Member Author

Choose a reason for hiding this comment

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

This was brought over from the old core package. A rename like this could be discussed though. cc @mayurkale22

import { Status } from './status';
import { TraceFlags } from './trace_flags';

export const INVALID_TRACE_ID = '0';
Copy link
Member

Choose a reason for hiding this comment

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

why is it 0 and not empty for example ?

Copy link
Member Author

Choose a reason for hiding this comment

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

This was the exact example in the old core package. I think because it needs to satisfy the typings of the TraceContext interface.

Copy link
Member

@OlivierAlbertini OlivierAlbertini left a comment

Choose a reason for hiding this comment

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

LGTM

packages/opentelemetry-api/README.md Outdated Show resolved Hide resolved
packages/opentelemetry-api/README.md Outdated Show resolved Hide resolved
packages/opentelemetry-api/README.md Outdated Show resolved Hide resolved
packages/opentelemetry-api/README.md Outdated Show resolved Hide resolved
packages/opentelemetry-api/README.md Outdated Show resolved Hide resolved
packages/opentelemetry-api/package.json Outdated Show resolved Hide resolved
Copy link
Member

@mayurkale22 mayurkale22 left a comment

Choose a reason for hiding this comment

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

lgtm

@mayurkale22 mayurkale22 added API and removed size/XXL labels Jan 23, 2020
@mayurkale22
Copy link
Member

@markwolff and @xiao-lix it would be nice if you can review this change.

Copy link
Member

@markwolff markwolff left a comment

Choose a reason for hiding this comment

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

Overall SGTM. Agree with the concept as I think it is what other SIGs (e.g python) were already doing.

@@ -205,19 +200,19 @@ describe('Meter', () => {

it('should return no op metric if name is an empty string', () => {
const counter = meter.createCounter('');
assert.ok(counter instanceof NoopMetric);
assert.ok(counter instanceof types.NoopMetric);
Copy link
Member

Choose a reason for hiding this comment

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

nit: I usually expect * as types imports to be only used for types and to be compiled away.

Copy link
Member Author

Choose a reason for hiding this comment

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

An instanceof cannot be compiled away because it is a runtime check. In any case, this is a test not deployed code.

Copy link
Member

Choose a reason for hiding this comment

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

Yes sorry I should have been more clear. I am proposing renaming this to * as core or * as api, but as you've stated this is only a test so its only a nit :)

Copy link
Member Author

Choose a reason for hiding this comment

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

Even if it wasn't a test, this is an instanceof check which is a runtime check that can't be compiled away.

Copy link
Member

@markwolff markwolff Jan 25, 2020

Choose a reason for hiding this comment

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

I agree. My point is that because it is not being compiled away, using import * as types here is misleading because it is being used for something other than just compile-time types.

@dyladan
Copy link
Member Author

dyladan commented Jan 27, 2020

Looks like one of our dependencies doesn't like node 8 anymore and requires 10 or higher

@nstawski
Copy link
Contributor

Will have to update the documentation in /getting-started in all places where @opentelemetry/types is used.

@mayurkale22 mayurkale22 merged commit 5d6c99d into open-telemetry:master Jan 29, 2020
@Flarna Flarna deleted the api-separation branch June 12, 2020 21:20
dyladan added a commit to dyladan/opentelemetry-js that referenced this pull request Sep 9, 2022
* feat: create an api package

* chore: update circle for new api package

* chore: bring back getTracer

* chore: add wrongly removed dev dependency

* chore: review comments

* chore: review comments

* chore: lint

* chore: export all noop implementations

* chore: update API README

* chore: ignore known working links that are not yet published

* chore: add jsdoc for getInstance calls

* chore: add jsdoc for private constructors

* chore: review comments

* chore: fix readme npm url

* chore: fix old readmes without registry

* chore: update api calling convention
pichlermarc pushed a commit to dynatrace-oss-contrib/opentelemetry-js that referenced this pull request Dec 15, 2023
* feat: create an api package

* chore: update circle for new api package

* chore: bring back getTracer

* chore: add wrongly removed dev dependency

* chore: review comments

* chore: review comments

* chore: lint

* chore: export all noop implementations

* chore: update API README

* chore: ignore known working links that are not yet published

* chore: add jsdoc for getInstance calls

* chore: add jsdoc for private constructors

* chore: review comments

* chore: fix readme npm url

* chore: fix old readmes without registry

* chore: update api calling convention
pichlermarc pushed a commit to dynatrace-oss-contrib/opentelemetry-js that referenced this pull request Dec 15, 2023
Co-authored-by: Amir Blum <amir@aspecto.io>
Co-authored-by: Bartlomiej Obecny <bobecny@gmail.com>
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.

Separate API from SDK
8 participants