Skip to content

Commit 6958d74

Browse files
committed
Add field "agent" to ProtoBuf NodeIdentity message
Metric and Span ingestion calls contain "agent" information. For consistency, boot and shutdown calls now do too. Kamon APM reporter back-end could use that information.
1 parent 7339c32 commit 6958d74

File tree

3 files changed

+221
-37
lines changed

3 files changed

+221
-37
lines changed

reporters/kamon-apm-reporter/src/main/java/kamino/IngestionV1.java

+217-35
Original file line numberDiff line numberDiff line change
@@ -4406,6 +4406,23 @@ public interface NodeIdentityOrBuilder extends
44064406
*/
44074407
com.google.protobuf.ByteString
44084408
getApiKeyBytes();
4409+
4410+
/**
4411+
* <code>optional string agent = 5;</code>
4412+
* @return Whether the agent field is set.
4413+
*/
4414+
boolean hasAgent();
4415+
/**
4416+
* <code>optional string agent = 5;</code>
4417+
* @return The agent.
4418+
*/
4419+
java.lang.String getAgent();
4420+
/**
4421+
* <code>optional string agent = 5;</code>
4422+
* @return The bytes for agent.
4423+
*/
4424+
com.google.protobuf.ByteString
4425+
getAgentBytes();
44094426
}
44104427
/**
44114428
* Protobuf type {@code NodeIdentity}
@@ -4424,6 +4441,7 @@ private NodeIdentity() {
44244441
instance_ = "";
44254442
host_ = "";
44264443
apiKey_ = "";
4444+
agent_ = "";
44274445
}
44284446

44294447
@java.lang.Override
@@ -4481,6 +4499,12 @@ private NodeIdentity(
44814499
apiKey_ = bs;
44824500
break;
44834501
}
4502+
case 42: {
4503+
com.google.protobuf.ByteString bs = input.readBytes();
4504+
bitField0_ |= 0x00000010;
4505+
agent_ = bs;
4506+
break;
4507+
}
44844508
default: {
44854509
if (!parseUnknownField(
44864510
input, unknownFields, extensionRegistry, tag)) {
@@ -4682,6 +4706,54 @@ public java.lang.String getApiKey() {
46824706
}
46834707
}
46844708

4709+
public static final int AGENT_FIELD_NUMBER = 5;
4710+
private volatile java.lang.Object agent_;
4711+
/**
4712+
* <code>optional string agent = 5;</code>
4713+
* @return Whether the agent field is set.
4714+
*/
4715+
@java.lang.Override
4716+
public boolean hasAgent() {
4717+
return ((bitField0_ & 0x00000010) != 0);
4718+
}
4719+
/**
4720+
* <code>optional string agent = 5;</code>
4721+
* @return The agent.
4722+
*/
4723+
@java.lang.Override
4724+
public java.lang.String getAgent() {
4725+
java.lang.Object ref = agent_;
4726+
if (ref instanceof java.lang.String) {
4727+
return (java.lang.String) ref;
4728+
} else {
4729+
com.google.protobuf.ByteString bs =
4730+
(com.google.protobuf.ByteString) ref;
4731+
java.lang.String s = bs.toStringUtf8();
4732+
if (bs.isValidUtf8()) {
4733+
agent_ = s;
4734+
}
4735+
return s;
4736+
}
4737+
}
4738+
/**
4739+
* <code>optional string agent = 5;</code>
4740+
* @return The bytes for agent.
4741+
*/
4742+
@java.lang.Override
4743+
public com.google.protobuf.ByteString
4744+
getAgentBytes() {
4745+
java.lang.Object ref = agent_;
4746+
if (ref instanceof java.lang.String) {
4747+
com.google.protobuf.ByteString b =
4748+
com.google.protobuf.ByteString.copyFromUtf8(
4749+
(java.lang.String) ref);
4750+
agent_ = b;
4751+
return b;
4752+
} else {
4753+
return (com.google.protobuf.ByteString) ref;
4754+
}
4755+
}
4756+
46854757
private byte memoizedIsInitialized = -1;
46864758
@java.lang.Override
46874759
public final boolean isInitialized() {
@@ -4724,6 +4796,9 @@ public void writeTo(com.google.protobuf.CodedOutputStream output)
47244796
if (((bitField0_ & 0x00000008) != 0)) {
47254797
com.google.protobuf.GeneratedMessageV3.writeString(output, 4, apiKey_);
47264798
}
4799+
if (((bitField0_ & 0x00000010) != 0)) {
4800+
com.google.protobuf.GeneratedMessageV3.writeString(output, 5, agent_);
4801+
}
47274802
unknownFields.writeTo(output);
47284803
}
47294804

@@ -4745,6 +4820,9 @@ public int getSerializedSize() {
47454820
if (((bitField0_ & 0x00000008) != 0)) {
47464821
size += com.google.protobuf.GeneratedMessageV3.computeStringSize(4, apiKey_);
47474822
}
4823+
if (((bitField0_ & 0x00000010) != 0)) {
4824+
size += com.google.protobuf.GeneratedMessageV3.computeStringSize(5, agent_);
4825+
}
47484826
size += unknownFields.getSerializedSize();
47494827
memoizedSize = size;
47504828
return size;
@@ -4780,6 +4858,11 @@ public boolean equals(final java.lang.Object obj) {
47804858
if (!getApiKey()
47814859
.equals(other.getApiKey())) return false;
47824860
}
4861+
if (hasAgent() != other.hasAgent()) return false;
4862+
if (hasAgent()) {
4863+
if (!getAgent()
4864+
.equals(other.getAgent())) return false;
4865+
}
47834866
if (!unknownFields.equals(other.unknownFields)) return false;
47844867
return true;
47854868
}
@@ -4807,6 +4890,10 @@ public int hashCode() {
48074890
hash = (37 * hash) + APIKEY_FIELD_NUMBER;
48084891
hash = (53 * hash) + getApiKey().hashCode();
48094892
}
4893+
if (hasAgent()) {
4894+
hash = (37 * hash) + AGENT_FIELD_NUMBER;
4895+
hash = (53 * hash) + getAgent().hashCode();
4896+
}
48104897
hash = (29 * hash) + unknownFields.hashCode();
48114898
memoizedHashCode = hash;
48124899
return hash;
@@ -4948,6 +5035,8 @@ public Builder clear() {
49485035
bitField0_ = (bitField0_ & ~0x00000004);
49495036
apiKey_ = "";
49505037
bitField0_ = (bitField0_ & ~0x00000008);
5038+
agent_ = "";
5039+
bitField0_ = (bitField0_ & ~0x00000010);
49515040
return this;
49525041
}
49535042

@@ -4992,6 +5081,10 @@ public kamino.IngestionV1.NodeIdentity buildPartial() {
49925081
to_bitField0_ |= 0x00000008;
49935082
}
49945083
result.apiKey_ = apiKey_;
5084+
if (((from_bitField0_ & 0x00000010) != 0)) {
5085+
to_bitField0_ |= 0x00000010;
5086+
}
5087+
result.agent_ = agent_;
49955088
result.bitField0_ = to_bitField0_;
49965089
onBuilt();
49975090
return result;
@@ -5061,6 +5154,11 @@ public Builder mergeFrom(kamino.IngestionV1.NodeIdentity other) {
50615154
apiKey_ = other.apiKey_;
50625155
onChanged();
50635156
}
5157+
if (other.hasAgent()) {
5158+
bitField0_ |= 0x00000010;
5159+
agent_ = other.agent_;
5160+
onChanged();
5161+
}
50645162
this.mergeUnknownFields(other.unknownFields);
50655163
onChanged();
50665164
return this;
@@ -5406,6 +5504,90 @@ public Builder setApiKeyBytes(
54065504
onChanged();
54075505
return this;
54085506
}
5507+
5508+
private java.lang.Object agent_ = "";
5509+
/**
5510+
* <code>optional string agent = 5;</code>
5511+
* @return Whether the agent field is set.
5512+
*/
5513+
public boolean hasAgent() {
5514+
return ((bitField0_ & 0x00000010) != 0);
5515+
}
5516+
/**
5517+
* <code>optional string agent = 5;</code>
5518+
* @return The agent.
5519+
*/
5520+
public java.lang.String getAgent() {
5521+
java.lang.Object ref = agent_;
5522+
if (!(ref instanceof java.lang.String)) {
5523+
com.google.protobuf.ByteString bs =
5524+
(com.google.protobuf.ByteString) ref;
5525+
java.lang.String s = bs.toStringUtf8();
5526+
if (bs.isValidUtf8()) {
5527+
agent_ = s;
5528+
}
5529+
return s;
5530+
} else {
5531+
return (java.lang.String) ref;
5532+
}
5533+
}
5534+
/**
5535+
* <code>optional string agent = 5;</code>
5536+
* @return The bytes for agent.
5537+
*/
5538+
public com.google.protobuf.ByteString
5539+
getAgentBytes() {
5540+
java.lang.Object ref = agent_;
5541+
if (ref instanceof String) {
5542+
com.google.protobuf.ByteString b =
5543+
com.google.protobuf.ByteString.copyFromUtf8(
5544+
(java.lang.String) ref);
5545+
agent_ = b;
5546+
return b;
5547+
} else {
5548+
return (com.google.protobuf.ByteString) ref;
5549+
}
5550+
}
5551+
/**
5552+
* <code>optional string agent = 5;</code>
5553+
* @param value The agent to set.
5554+
* @return This builder for chaining.
5555+
*/
5556+
public Builder setAgent(
5557+
java.lang.String value) {
5558+
if (value == null) {
5559+
throw new NullPointerException();
5560+
}
5561+
bitField0_ |= 0x00000010;
5562+
agent_ = value;
5563+
onChanged();
5564+
return this;
5565+
}
5566+
/**
5567+
* <code>optional string agent = 5;</code>
5568+
* @return This builder for chaining.
5569+
*/
5570+
public Builder clearAgent() {
5571+
bitField0_ = (bitField0_ & ~0x00000010);
5572+
agent_ = getDefaultInstance().getAgent();
5573+
onChanged();
5574+
return this;
5575+
}
5576+
/**
5577+
* <code>optional string agent = 5;</code>
5578+
* @param value The bytes for agent to set.
5579+
* @return This builder for chaining.
5580+
*/
5581+
public Builder setAgentBytes(
5582+
com.google.protobuf.ByteString value) {
5583+
if (value == null) {
5584+
throw new NullPointerException();
5585+
}
5586+
bitField0_ |= 0x00000010;
5587+
agent_ = value;
5588+
onChanged();
5589+
return this;
5590+
}
54095591
@java.lang.Override
54105592
public final Builder setUnknownFields(
54115593
final com.google.protobuf.UnknownFieldSet unknownFields) {
@@ -14152,41 +14334,41 @@ public kamino.IngestionV1.Link getDefaultInstanceForType() {
1415214334
"c\022\014\n\004name\030\001 \002(\t\022\037\n\004tags\030\002 \003(\0132\021.Metric.T" +
1415314335
"agsEntry\022\'\n\016instrumentType\030\003 \002(\0162\017.Instr" +
1415414336
"umentType\022\014\n\004data\030\004 \002(\014\032+\n\tTagsEntry\022\013\n\003" +
14155-
"key\030\001 \001(\t\022\r\n\005value\030\002 \001(\t:\0028\001\"O\n\014NodeIden" +
14337+
"key\030\001 \001(\t\022\r\n\005value\030\002 \001(\t:\0028\001\"^\n\014NodeIden" +
1415614338
"tity\022\017\n\007service\030\001 \002(\t\022\020\n\010instance\030\002 \002(\t\022" +
14157-
"\014\n\004host\030\003 \002(\t\022\016\n\006apiKey\030\004 \002(\t\"X\n\005Hello\022\033" +
14158-
"\n\004node\030\001 \002(\0132\r.NodeIdentity\022\014\n\004time\030\002 \002(" +
14159-
"\003\022\023\n\013incarnation\030\003 \002(\t\022\017\n\007version\030\004 \002(\t\"" +
14160-
"4\n\007Goodbye\022\033\n\004node\030\001 \002(\0132\r.NodeIdentity\022" +
14161-
"\014\n\004time\030\002 \002(\003\"u\n\tSpanBatch\022\023\n\013serviceNam" +
14162-
"e\030\001 \002(\t\022\016\n\006apiKey\030\002 \002(\t\022\014\n\004host\030\003 \002(\t\022\020\n" +
14163-
"\010instance\030\004 \002(\t\022\024\n\005spans\030\005 \003(\0132\005.Span\022\r\n" +
14164-
"\005agent\030\006 \001(\t\"$\n\004Mark\022\017\n\007instant\030\001 \002(\003\022\013\n" +
14165-
"\003key\030\002 \002(\t\"\252\003\n\004Span\022\n\n\002id\030\001 \002(\t\022\017\n\007trace" +
14166-
"Id\030\002 \002(\t\022\020\n\010parentId\030\003 \002(\t\022\025\n\roperationN" +
14167-
"ame\030\004 \002(\t\022\023\n\013startMicros\030\005 \002(\003\022\021\n\tendMic" +
14168-
"ros\030\006 \002(\003\022\035\n\004tags\030\007 \003(\0132\017.Span.TagsEntry" +
14169-
"\022\024\n\005marks\030\010 \003(\0132\005.Mark\022\020\n\010hasError\030\t \001(\010" +
14170-
"\022\022\n\nwasDelayed\030\n \001(\010\022\027\n\004kind\030\013 \001(\0162\t.Spa" +
14171-
"nKind\022\037\n\010position\030\014 \001(\0162\r.SpanPosition\022)" +
14172-
"\n\nmetricTags\030\r \003(\0132\025.Span.MetricTagsEntr" +
14173-
"y\022\024\n\005links\030\016 \003(\0132\005.Link\032+\n\tTagsEntry\022\013\n\003" +
14174-
"key\030\001 \001(\t\022\r\n\005value\030\002 \001(\t:\0028\001\0321\n\017MetricTa" +
14175-
"gsEntry\022\013\n\003key\030\001 \001(\t\022\r\n\005value\030\002 \001(\t:\0028\001\"" +
14176-
"5\n\021IngestionResponse\022 \n\006status\030\001 \002(\0162\020.I" +
14177-
"ngestionStatus\"@\n\004Link\022\027\n\004kind\030\001 \002(\0162\t.L" +
14178-
"inkKind\022\017\n\007traceId\030\002 \002(\t\022\016\n\006spanId\030\003 \002(\t" +
14179-
"*L\n\016InstrumentType\022\013\n\007COUNTER\020\000\022\t\n\005GAUGE" +
14180-
"\020\001\022\r\n\tHISTOGRAM\020\002\022\023\n\017MIN_MAX_COUNTER\020\003*+" +
14181-
"\n\004Plan\022\017\n\013METRIC_ONLY\020\001\022\022\n\016METRIC_TRACIN" +
14182-
"G\020\002*]\n\017IngestionStatus\022\006\n\002OK\020\000\022\t\n\005ERROR\020" +
14183-
"\001\022\t\n\005STALE\020\002\022\020\n\014UNAUTHORIZED\020\003\022\013\n\007BLOCKE" +
14184-
"D\020\004\022\r\n\tCORRUPTED\020\005*Y\n\010SpanKind\022\013\n\007UNKNOW" +
14185-
"N\020\000\022\n\n\006SERVER\020\001\022\n\n\006CLIENT\020\002\022\014\n\010PRODUCER\020" +
14186-
"\003\022\014\n\010CONSUMER\020\004\022\014\n\010INTERNAL\020\005*>\n\014SpanPos" +
14187-
"ition\022\024\n\020POSITION_UNKNOWN\020\000\022\010\n\004ROOT\020\001\022\016\n" +
14188-
"\nLOCAL_ROOT\020\002*\034\n\010LinkKind\022\020\n\014FOLLOWS_FRO" +
14189-
"M\020\001B\010\n\006kamino"
14339+
"\014\n\004host\030\003 \002(\t\022\016\n\006apiKey\030\004 \002(\t\022\r\n\005" +
14340+
"agent\030\005 \001(\t\"X\n\005Hello\022\033\n\004node\030\001 \002(\0132\r.Nod" +
14341+
"eIdentity\022\014\n\004time\030\002 \002(\003\022\023\n\013incarnation\030\003" +
14342+
" \002(\t\022\017\n\007version\030\004 \002(\t\"4\n\007Goodbye\022\033\n\004node" +
14343+
"\030\001 \002(\0132\r.NodeIdentity\022\014\n\004time\030\002 \002(\003\"u\n\tS" +
14344+
"panBatch\022\023\n\013serviceName\030\001 \002(\t\022\016\n\006apiKey\030" +
14345+
"\002 \002(\t\022\014\n\004host\030\003 \002(\t\022\020\n\010instance\030\004 \002(\t\022\024\n" +
14346+
"\005spans\030\005 \003(\0132\005.Span\022\r\n\005agent\030\006 \001(\t\"$\n\004Ma" +
14347+
"rk\022\017\n\007instant\030\001 \002(\003\022\013\n\003key\030\002 \002(\t\"\252\003\n\004Spa" +
14348+
"n\022\n\n\002id\030\001 \002(\t\022\017\n\007traceId\030\002 \002(\t\022\020\n\010parent" +
14349+
"Id\030\003 \002(\t\022\025\n\roperationName\030\004 \002(\t\022\023\n\013start" +
14350+
"Micros\030\005 \002(\003\022\021\n\tendMicros\030\006 \002(\003\022\035\n\004tags\030" +
14351+
"\007 \003(\0132\017.Span.TagsEntry\022\024\n\005marks\030\010 \003(\0132\005." +
14352+
"Mark\022\020\n\010hasError\030\t \001(\010\022\022\n\nwasDelayed\030\n \001" +
14353+
"(\010\022\027\n\004kind\030\013 \001(\0162\t.SpanKind\022\037\n\010position\030" +
14354+
"\014 \001(\0162\r.SpanPosition\022)\n\nmetricTags\030\r \003(\013" +
14355+
"2\025.Span.MetricTagsEntry\022\024\n\005links\030\016 \003(\0132\005" +
14356+
".Link\032+\n\tTagsEntry\022\013\n\003key\030\001 \001(\t\022\r\n\005value" +
14357+
"\030\002 \001(\t:\0028\001\0321\n\017MetricTagsEntry\022\013\n\003key\030\001 \001" +
14358+
"(\t\022\r\n\005value\030\002 \001(\t:\0028\001\"5\n\021IngestionRespon" +
14359+
"se\022 \n\006status\030\001 \002(\0162\020.IngestionStatus\"@\n\004" +
14360+
"Link\022\027\n\004kind\030\001 \002(\0162\t.LinkKind\022\017\n\007traceId" +
14361+
"\030\002 \002(\t\022\016\n\006spanId\030\003 \002(\t*L\n\016InstrumentType" +
14362+
"\022\013\n\007COUNTER\020\000\022\t\n\005GAUGE\020\001\022\r\n\tHISTOGRAM\020\002\022" +
14363+
"\023\n\017MIN_MAX_COUNTER\020\003*+\n\004Plan\022\017\n\013METRIC_O" +
14364+
"NLY\020\001\022\022\n\016METRIC_TRACING\020\002*]\n\017IngestionSt" +
14365+
"atus\022\006\n\002OK\020\000\022\t\n\005ERROR\020\001\022\t\n\005STALE\020\002\022\020\n\014UN" +
14366+
"AUTHORIZED\020\003\022\013\n\007BLOCKED\020\004\022\r\n\tCORRUPTED\020\005" +
14367+
"*Y\n\010SpanKind\022\013\n\007UNKNOWN\020\000\022\n\n\006SERVER\020\001\022\n\n" +
14368+
"\006CLIENT\020\002\022\014\n\010PRODUCER\020\003\022\014\n\010CONSUMER\020\004\022\014\n" +
14369+
"\010INTERNAL\020\005*>\n\014SpanPosition\022\024\n\020POSITION_" +
14370+
"UNKNOWN\020\000\022\010\n\004ROOT\020\001\022\016\n\nLOCAL_ROOT\020\002*\034\n\010L" +
14371+
"inkKind\022\020\n\014FOLLOWS_FROM\020\001B\010\n\006kamino"
1419014372
};
1419114373
descriptor = com.google.protobuf.Descriptors.FileDescriptor
1419214374
.internalBuildGeneratedFileFrom(descriptorData,
@@ -14221,7 +14403,7 @@ public kamino.IngestionV1.Link getDefaultInstanceForType() {
1422114403
internal_static_NodeIdentity_fieldAccessorTable = new
1422214404
com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
1422314405
internal_static_NodeIdentity_descriptor,
14224-
new java.lang.String[] { "Service", "Instance", "Host", "ApiKey", });
14406+
new java.lang.String[] { "Service", "Instance", "Host", "ApiKey", "Agent", });
1422514407
internal_static_Hello_descriptor =
1422614408
getDescriptor().getMessageTypes().get(4);
1422714409
internal_static_Hello_fieldAccessorTable = new

reporters/kamon-apm-reporter/src/main/protobuf/ingestion.v1.proto

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ message NodeIdentity {
4242
required string instance = 2;
4343
required string host = 3;
4444
required string apiKey = 4;
45+
optional string agent = 5;
4546
}
4647

4748
message Hello {

reporters/kamon-apm-reporter/src/main/scala/kamon/apm/KamonApm.scala

+3-2
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ class KamonApm(configPath: String) extends CombinedReporter {
132132

133133
private def reportBoot(initializationTimestamp: Long): Unit = {
134134
val hello = IngestionV1.Hello.newBuilder()
135-
.setNode(nodeIdentity)
135+
.setNode(nodeIdentity())
136136
.setTime(initializationTimestamp)
137137
.setIncarnation(Kamon.environment.incarnation)
138138
.setVersion(_settings.appVersion)
@@ -143,7 +143,7 @@ class KamonApm(configPath: String) extends CombinedReporter {
143143

144144
private def reportShutdown(shutdownTimestamp: Long): Unit = {
145145
val goodBye = IngestionV1.Goodbye.newBuilder()
146-
.setNode(nodeIdentity)
146+
.setNode(nodeIdentity())
147147
.setTime(shutdownTimestamp)
148148
.build()
149149

@@ -158,6 +158,7 @@ class KamonApm(configPath: String) extends CombinedReporter {
158158
.setInstance(env.instance)
159159
.setHost(env.host)
160160
.setApiKey(_settings.apiKey)
161+
.setAgent(_settings.agent)
161162
.build()
162163
}
163164

0 commit comments

Comments
 (0)