-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Manage span metadata better, add more exception metadata (#20)
* Manage span metadata better, add more exception metadata * Add missing file
- Loading branch information
Showing
4 changed files
with
112 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
natchez-datadog/src/main/scala/com/ovoenergy/effect/natchez/DatadogTags.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package com.ovoenergy.effect.natchez | ||
|
||
import natchez.TraceValue | ||
|
||
/** | ||
* Some helper functions to construct Datadog tags, | ||
* I took these from the DD-Trace-Java library | ||
*/ | ||
object DatadogTags { | ||
|
||
sealed trait SpanType | ||
|
||
object SpanType { | ||
case object Web extends SpanType | ||
case object Db extends SpanType | ||
} | ||
|
||
def env(env: String): (String, TraceValue) = | ||
"env" -> env | ||
|
||
def spanType(spanType: SpanType): (String, TraceValue) = | ||
"span.type" -> spanType.toString | ||
|
||
def serviceName(name: String): (String, TraceValue) = | ||
"service.name" -> name | ||
|
||
def sqlQuery(query: String): (String, TraceValue) = | ||
"sql.query" -> query | ||
|
||
def httpMethod(method: String): (String, TraceValue) = | ||
"http.method" -> method | ||
|
||
def httpStatusCode(code: Int): (String, TraceValue) = | ||
"http.status_code" -> code | ||
|
||
def httpUrl(url: String): (String, TraceValue) = | ||
"http.url" -> url | ||
|
||
def errorMessage(what: String): (String, TraceValue) = | ||
"error.msg" -> what | ||
|
||
def errorType(what: String): (String, TraceValue) = | ||
"error.type" -> what | ||
|
||
def errorStack(what: String): (String, TraceValue) = | ||
"error.stack" -> what | ||
|
||
def forThrowable(e: Throwable): Map[String, TraceValue] = | ||
List( | ||
errorMessage(e.getMessage), | ||
errorType(e.getClass.getSimpleName), | ||
errorStack(e.getStackTrace.mkString("\n")) | ||
).toMap | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters