File tree Expand file tree Collapse file tree 7 files changed +14
-0
lines changed
exporter-logs-otlp-grpc/test
exporter-logs-otlp-http/test
exporter-logs-otlp-proto/test Expand file tree Collapse file tree 7 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,8 @@ All notable changes to experimental packages in this project will be documented
88
99### :rocket : (Enhancement)
1010
11+ * feat(sdk-logs): add droppedAttributesCount field to ReadableLogRecord
12+
1113### :bug : (Bug Fix)
1214
1315* fix(sdk-logs): avoid map attribute set when count limit exceeded
Original file line number Diff line number Diff line change @@ -49,6 +49,7 @@ export const mockedReadableLogRecord: ReadableLogRecord = {
4949 attributes : {
5050 'some-attribute' : 'some attribute value' ,
5151 } ,
52+ droppedAttributesCount : 0 ,
5253 severityNumber : SeverityNumber . ERROR ,
5354 severityText : 'error' ,
5455 body : 'some_log_body' ,
Original file line number Diff line number Diff line change @@ -44,6 +44,7 @@ export const mockedReadableLogRecord: ReadableLogRecord = {
4444 attributes : {
4545 'some-attribute' : 'some attribute value' ,
4646 } ,
47+ droppedAttributesCount : 0 ,
4748 severityNumber : SeverityNumber . ERROR ,
4849 severityText : 'error' ,
4950 body : 'some_log_body' ,
Original file line number Diff line number Diff line change @@ -45,6 +45,7 @@ export const mockedReadableLogRecord: ReadableLogRecord = {
4545 attributes : {
4646 'some-attribute' : 'some attribute value' ,
4747 } ,
48+ droppedAttributesCount : 0 ,
4849 severityNumber : SeverityNumber . ERROR ,
4950 severityText : 'error' ,
5051 body : 'some_log_body' ,
Original file line number Diff line number Diff line change @@ -107,6 +107,7 @@ describe('Logs', () => {
107107 attributes : {
108108 'some-attribute' : 'some attribute value' ,
109109 } ,
110+ droppedAttributesCount : 0 ,
110111 severityNumber : SeverityNumber . ERROR ,
111112 severityText : 'error' ,
112113 body : 'some_log_body' ,
@@ -122,6 +123,7 @@ describe('Logs', () => {
122123 attributes : {
123124 'another-attribute' : 'another attribute value' ,
124125 } ,
126+ droppedAttributesCount : 0 ,
125127 } ;
126128 log_1_1_1 = {
127129 ...log_fragment_1 ,
Original file line number Diff line number Diff line change @@ -39,6 +39,7 @@ export class LogRecord implements ReadableLogRecord {
3939 private _severityText ?: string ;
4040 private _severityNumber ?: logsAPI . SeverityNumber ;
4141 private _body ?: string ;
42+ private totalAttributesCount : number = 0 ;
4243
4344 private _isReadonly : boolean = false ;
4445 private readonly _logRecordLimits : Required < LogRecordLimits > ;
@@ -73,6 +74,10 @@ export class LogRecord implements ReadableLogRecord {
7374 return this . _body ;
7475 }
7576
77+ get droppedAttributesCount ( ) : number {
78+ return this . totalAttributesCount - Object . keys ( this . attributes ) . length ;
79+ }
80+
7681 constructor (
7782 _sharedState : LoggerProviderSharedState ,
7883 instrumentationScope : InstrumentationScope ,
@@ -129,6 +134,7 @@ export class LogRecord implements ReadableLogRecord {
129134 api . diag . warn ( `Invalid attribute value set for key: ${ key } ` ) ;
130135 return this ;
131136 }
137+ this . totalAttributesCount += 1 ;
132138 if (
133139 Object . keys ( this . attributes ) . length >=
134140 this . _logRecordLimits . attributeCountLimit &&
Original file line number Diff line number Diff line change @@ -29,4 +29,5 @@ export interface ReadableLogRecord {
2929 readonly resource : IResource ;
3030 readonly instrumentationScope : InstrumentationScope ;
3131 readonly attributes : LogAttributes ;
32+ readonly droppedAttributesCount : number ;
3233}
You can’t perform that action at this time.
0 commit comments