-
Notifications
You must be signed in to change notification settings - Fork 144
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #866 from StanlieK/feature/mdc-in-log-forwarding
NR-23881 - Give users possibility to add MDC to logging
- Loading branch information
Showing
43 changed files
with
907 additions
and
511 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
52 changes: 52 additions & 0 deletions
52
agent-bridge/src/main/java/com/newrelic/agent/bridge/logging/LogAttributeKey.java
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,52 @@ | ||
/* | ||
* | ||
* * Copyright 2022 New Relic Corporation. All rights reserved. | ||
* * SPDX-License-Identifier: Apache-2.0 | ||
* | ||
*/ | ||
|
||
package com.newrelic.agent.bridge.logging; | ||
|
||
import java.util.Objects; | ||
|
||
public class LogAttributeKey { | ||
public final String key; | ||
public final LogAttributeType type; | ||
|
||
public LogAttributeKey(String key, LogAttributeType type) { | ||
this.key = key; | ||
this.type = type; | ||
} | ||
|
||
public String getKey() { | ||
return key; | ||
} | ||
|
||
public String getPrefixedKey() { | ||
if (key == null || type == null) { | ||
return key; | ||
} | ||
return type.applyPrefix(key); | ||
} | ||
|
||
public LogAttributeType getType() { | ||
return type; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) { | ||
return true; | ||
} | ||
if (o == null || getClass() != o.getClass()) { | ||
return false; | ||
} | ||
LogAttributeKey that = (LogAttributeKey) o; | ||
return Objects.equals(key, that.key) && type == that.type; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(key, type); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
agent-bridge/src/main/java/com/newrelic/agent/bridge/logging/LogAttributeType.java
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,28 @@ | ||
/* | ||
* | ||
* * Copyright 2022 New Relic Corporation. All rights reserved. | ||
* * SPDX-License-Identifier: Apache-2.0 | ||
* | ||
*/ | ||
|
||
package com.newrelic.agent.bridge.logging; | ||
|
||
public enum LogAttributeType { | ||
AGENT(null) { | ||
@Override | ||
public String applyPrefix(String key) { | ||
return key; | ||
} | ||
}, | ||
CONTEXT(AppLoggingUtils.CONTEXT_DATA_ATTRIBUTE_PREFIX); | ||
|
||
private final String prefix; | ||
|
||
LogAttributeType(String prefix) { | ||
this.prefix = prefix; | ||
} | ||
|
||
public String applyPrefix(String key) { | ||
return prefix.concat(key); | ||
} | ||
} |
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
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
Oops, something went wrong.