Skip to content

Commit

Permalink
Merge pull request #252 from solarwinds/NH-73038
Browse files Browse the repository at this point in the history
Don't send empty http.* attributes in metrics
  • Loading branch information
raphael-theriault-swi authored Feb 15, 2024
2 parents fb7de50 + 2303934 commit 6785a54
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
3 changes: 3 additions & 0 deletions .yarn/versions/cfc065c7.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
releases:
"@solarwinds-apm/sdk": patch
solarwinds-apm: patch
23 changes: 17 additions & 6 deletions packages/sdk/src/metrics/serverless.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

import { metrics, SpanStatusCode, ValueType } from "@opentelemetry/api"
import {
type Attributes,
metrics,
SpanStatusCode,
ValueType,
} from "@opentelemetry/api"
import { hrTimeToMilliseconds } from "@opentelemetry/core"
import { Aggregation, View } from "@opentelemetry/sdk-metrics"
import { type ReadableSpan } from "@opentelemetry/sdk-trace-base"
Expand Down Expand Up @@ -83,12 +88,18 @@ export function recordServerlessResponseTime(

const time = hrTimeToMilliseconds(span.duration)

responseTime.record(time, {
[SemanticAttributes.HTTP_METHOD]: method,
[SemanticAttributes.HTTP_STATUS_CODE]: statusCode,
"sw.is_error": isError,
const attrs: Attributes = {
"sw.transaction": transaction ?? "unknown",
})
"sw.is_error": isError,
}
if (method) {
attrs[SemanticAttributes.HTTP_METHOD] = method
}
if (statusCode) {
attrs[SemanticAttributes.HTTP_STATUS_CODE] = statusCode
}

responseTime.record(time, attrs)
}

export const serverlessViews = [
Expand Down

0 comments on commit 6785a54

Please sign in to comment.