Skip to content

Commit

Permalink
0.35.3: push more details to query log
Browse files Browse the repository at this point in the history
  • Loading branch information
hayco committed Jul 1, 2024
1 parent 6e1dc95 commit 2a3a986
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 40 deletions.
54 changes: 28 additions & 26 deletions config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ logging:
archivedLogFilenamePattern: ./query-log-%d.gz
archivedFileCount: 5
timeZone: UTC
logFormat: "%d{ISO8601,UTC}|%m%n"
logFormat: "%d{ISO8601,UTC}|%m|%kvp%n"
bufferSize: 256KiB
immediateFlush: true
filterFactories:
Expand All @@ -46,7 +46,6 @@ projects:
- name: 'globalise'
textType: LogicalText
annoRepo:
apiKey: 02d01d02-be58-4e9e-95c2-387715996bb5
containerName: globalise-2024-03-18
uri: https://annorepo.globalise.huygens.knaw.nl
brinta:
Expand All @@ -67,7 +66,6 @@ projects:
path: "$.body.metadata.document"
type: keyword
textRepo:
apiKey: YnJhbWI6MmMxNmNmNDQtYjcxZC0xMWVjLTgxZmUtOGYyZWJkZjU1Nzdl
uri: https://globalise.tt.di.huc.knaw.nl

- name: 'mondriaan'
Expand Down Expand Up @@ -162,30 +160,18 @@ projects:
deleteKey: 'republic-dev-mag-weg'
joinSeparator: " "
indices:
- name: 'republic-2024.05.17'
bodyTypes: [ Resolution, Entity, AttendanceList ]
- name: 'republic-2024.06.18'
bodyTypes: [ Resolution ]
fields:
- name: bodyType
path: "$.body.type"
type: keyword
- name: entityCategory
path: "$.body.metadata.category"
type: keyword
- name: entityId
path: "$.body.metadata.entityId"
type: keyword
- name: entityLabels
path: "$.body.metadata.entityLabels"
type: keyword
- name: entityName
path: "$.body.metadata.name"
type: keyword
- name: propositionType
path: "$.body.metadata.propositionType"
type: keyword
- name: resolutionType
path: "$.body.metadata.resolutionType"
type: keyword
- name: textType
path: "$.body.metadata.textType"
type: keyword
- name: sessionDate
path: "$.body.metadata.sessionDate"
type: date
Expand All @@ -198,19 +184,36 @@ projects:
- name: sessionYear
path: "$.body.metadata.sessionYear"
type: short
- name: delegateId
path: "$.body.metadata.delegateId"
type: keyword
- name: delegateName
path: "$.body.metadata.delegateName"
type: keyword
- name: entityCategory
path: "$.body.metadata.category"
type: keyword
- name: entityId
path: "$.body.metadata.entityId"
type: keyword
- name: entityLabels
path: "$.body.metadata.entityLabels"
type: keyword
- name: entityName
path: "$.body.metadata.name"
type: keyword
- name: bodyType
path: "$.body.type"
type: keyword
- name: sessionWeekday
path: "$.body.metadata.sessionWeekday"
type: keyword
- name: textType
path: "$.body.metadata.textType"
type: keyword
annoRepo:
containerName: republic-2024.05.17
containerName: republic-2024.06.18
uri: https://annorepo.republic-caf.diginfra.org
textRepo:
uri: https://textrepo.republic-caf.diginfra.org


- name: 'suriano'
topTierBodyType: tf:File
brinta:
Expand Down Expand Up @@ -262,7 +265,6 @@ projects:
path: "$.body.type"
type: keyword
textRepo:
apiKey: cHJveWNvbjo5Y2I2YTIyZS1jY2M5LTExZWUtYTllZS0zMzNmNDQ2YjBjZTE=
uri: https://brieven-van-hooft.tt.di.huc.knaw.nl

- name: 'vangogh'
Expand Down
14 changes: 9 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>nl.knaw.huc</groupId>
<artifactId>broccoli</artifactId>
<version>0.35.2</version>
<version>0.35.3</version>

<packaging>jar</packaging>

Expand Down Expand Up @@ -104,8 +104,10 @@
<configuration>
<createDependencyReducedPom>true</createDependencyReducedPom>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<transformer
implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>${mainClass}</mainClass>
</transformer>
</transformers>
Expand Down Expand Up @@ -142,8 +144,10 @@
</goals>
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<transformer
implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>${mainClass}</mainClass>
</transformer>
</transformers>
Expand Down
17 changes: 11 additions & 6 deletions src/main/kotlin/nl/knaw/huc/broccoli/api/IndexQuery.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,17 @@ data class IndexQuery(

@JsonProperty("aggs")
val aggregations: List<String>? = null
)
) {
override fun toString(): String = buildString {
text?.let { append(it).append('|') }
date?.let { append(it).append('|') }
range?.let { append(it).append('|') }
terms?.let { append(it).append('|') }
}
}

typealias IndexTerms = Map<String, List<String>>

data class IndexRange(
val name: String,
val from: String?,
val to: String?
)
data class IndexRange(val name: String, val from: String?, val to: String?) {
override fun toString(): String = "$name:[$from,$to]"
}
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class ProjectsResource(
find { it == sortBy } ?: throw BadRequestException("query param sortBy must be one of ${this.sorted()}")
}

logQuery(queryString)
logQuery(queryString, from, size)

val queryBuilder = ElasticQueryBuilder(index)
.query(queryString)
Expand Down Expand Up @@ -169,11 +169,11 @@ class ProjectsResource(
}
}

private fun logQuery(query: IndexQuery) {
private fun logQuery(query: IndexQuery, from: Int, size: Int) {
if (query.text != null) {
logger.atDebug()
.addMarker(queryMarker)
.setMessage(jsonWriter.writeValueAsString(query.text))
.setMessage("${query}from=$from|size=$size")
.log()
}
}
Expand Down

0 comments on commit 2a3a986

Please sign in to comment.