29
29
record /4 ,
30
30
record /5 ]).
31
31
32
+ -include_lib (" opentelemetry_api/include/opentelemetry.hrl" ).
32
33
-include_lib (" kernel/include/logger.hrl" ).
33
34
-include_lib (" opentelemetry_api_experimental/include/otel_metrics.hrl" ).
34
35
-include (" otel_metrics.hrl" ).
@@ -44,14 +45,8 @@ create_instrument(Meter, Name, Kind, Opts) ->
44
45
_ = otel_meter_server :add_instrument (Provider , Instrument ),
45
46
Instrument .
46
47
47
- lookup_instrument (Meter = {_ , # meter {instruments_tab = Tab }}, Name ) ->
48
- try ets :lookup_element (Tab , {Meter , Name }, 2 ) of
49
- Instrument ->
50
- Instrument
51
- catch
52
- _ :_ ->
53
- undefined
54
- end .
48
+ lookup_instrument ({_ , Meter = # meter {instruments_tab = InstrumentsTab }}, Name ) ->
49
+ otel_metrics_tables :lookup_instrument (InstrumentsTab , Meter , Name ).
55
50
56
51
-spec create_instrument (otel_meter :t (), otel_instrument :name (), otel_instrument :kind (), otel_instrument :callback (), otel_instrument :callback_args (), otel_instrument :opts ()) -> otel_instrument :t ().
57
52
create_instrument (Meter , Name , Kind , Callback , CallbackArgs , Opts ) ->
@@ -67,7 +62,10 @@ register_callback({_, #meter{provider=Provider}}, Instruments, Callback, Callbac
67
62
register_callback (_ , _ , _ , _ ) ->
68
63
ok .
69
64
65
+ -spec scope ({module (), # meter {}} | # meter {}) -> opentelemetry :instrumentation_scope () | undefined .
70
66
scope ({_ , # meter {instrumentation_scope = Scope }}) ->
67
+ Scope ;
68
+ scope (# meter {instrumentation_scope = Scope }) ->
71
69
Scope .
72
70
73
71
validate_name (Name ) when is_atom (Name ) ->
@@ -116,15 +114,11 @@ validate_explicit_bucket_boundaries(Name, Value) ->
116
114
record (Ctx , Instrument = # instrument {}, Number ) ->
117
115
record (Ctx , Instrument , Number , #{}).
118
116
119
- record (Ctx , Meter = {_ ,# meter {}}, NameOrInstrument , Number ) ->
117
+ record (Ctx , Meter = {_ , # meter {}}, NameOrInstrument , Number ) ->
120
118
record (Ctx , Meter , NameOrInstrument , Number , #{});
121
119
122
- record (Ctx , Instrument = # instrument {meter = {_ , # meter {streams_tab = StreamTab ,
123
- metrics_tab = MetricsTab ,
124
- exemplars_tab = ExemplarsTab }}}, Number , Attributes ) ->
125
- otel_meter_server :record (Ctx , StreamTab , MetricsTab , ExemplarsTab , Instrument , Number , Attributes ).
120
+ record (Ctx , Instrument = # instrument {meter = {_ , Meter = # meter {}}}, Number , Attributes ) ->
121
+ otel_meter_server :record (Ctx , Meter , Instrument , Number , Attributes ).
126
122
127
- record (Ctx , Meter = {_ , # meter {streams_tab = StreamTab ,
128
- metrics_tab = MetricsTab ,
129
- exemplars_tab = ExemplarsTab }}, NameOrInstrument , Number , Attributes ) ->
130
- otel_meter_server :record (Ctx , Meter , StreamTab , MetricsTab , ExemplarsTab , NameOrInstrument , Number , Attributes ).
123
+ record (Ctx , {_ , Meter }, NameOrInstrument , Number , Attributes ) ->
124
+ otel_meter_server :record (Ctx , Meter , NameOrInstrument , Number , Attributes ).
0 commit comments