Skip to content

Api separation#727

Merged
mayurkale22 merged 20 commits intoopen-telemetry:masterfrom
dynatrace-oss-contrib:api-separation
Jan 29, 2020
Merged

Api separation#727
mayurkale22 merged 20 commits intoopen-telemetry:masterfrom
dynatrace-oss-contrib:api-separation

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

Attention: Patch coverage is 92.51701% with 11 lines in your changes missing coverage. Please review.

Project coverage is 90.90%. Comparing base (4a83613) to head (ebab028).

Files with missing lines Patch % Lines
packages/opentelemetry-api/src/api/metrics.ts 53.33% 7 Missing ⚠️
packages/opentelemetry-api/src/api/trace.ts 86.66% 2 Missing ⚠️
.../opentelemetry-api/src/trace/NoopTracerRegistry.ts 60.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #727      +/-   ##
==========================================
- Coverage   92.59%   90.90%   -1.69%     
==========================================
  Files         226      233       +7     
  Lines       10216    10506     +290     
  Branches      925      962      +37     
==========================================
+ Hits         9460     9551      +91     
- Misses        756      955     +199     
Files with missing lines Coverage Δ
...ry-api/src/context/propagation/NoopBinaryFormat.ts 100.00% <100.00%> (ø)
...-api/src/context/propagation/NoopHttpTextFormat.ts 100.00% <100.00%> (ø)
...elemetry-api/src/distributed_context/EntryValue.ts 100.00% <ø> (ø)
packages/opentelemetry-api/src/metrics/Metric.ts 100.00% <ø> (ø)
...ackages/opentelemetry-api/src/metrics/NoopMeter.ts 81.13% <100.00%> (ø)
...opentelemetry-api/src/metrics/NoopMeterRegistry.ts 100.00% <100.00%> (ø)
packages/opentelemetry-api/src/trace/NoopSpan.ts 100.00% <100.00%> (ø)
packages/opentelemetry-api/src/trace/NoopTracer.ts 100.00% <100.00%> (ø)
packages/opentelemetry-api/src/trace/span_kind.ts 100.00% <ø> (ø)
packages/opentelemetry-api/src/trace/status.ts 100.00% <ø> (ø)
... and 113 more

... and 74 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

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

}

/**
* 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.

@dyladan dyladan requested a review from mayurkale22 January 23, 2020 15:06
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

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.

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